home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / prog_d / oleauttr.zip / GRAPHOLE.ZIP / GRAPHCLS.PAS next >
Pascal/Delphi Source File  |  1996-01-01  |  3KB  |  109 lines

  1. unit Graphcls;
  2. {
  3. //__________________________________________________________________________
  4. // Unit File  : GRAPHCLS.PAS
  5. // Summary    :
  6. // Author     : William M. Raike
  7. // Created on : 31 Dec 1995
  8. // Project    :
  9. // Compiler   : Borland Delphi 1.0
  10. //__________________________________________________________________________
  11. //                       INTERFACE CHANGE HISTORY
  12. //  No.    When    Who    Why
  13. //  0           WMR  Original File.
  14. //
  15. //__________________________________________________________________________
  16. //
  17. // Description:
  18.       Mirror class for MS-GRAPH OLE Automation server, describing
  19.       Application sub-object with its Visible property.  Illustrates
  20.       accessing nested objects using TOLEAutoClient component.
  21. }
  22.  
  23. interface
  24.  
  25. uses
  26.   OleAuto;
  27.  
  28. type
  29.  
  30.   { Describes Application object nested within top-level
  31.     MSGraph.Chart server object.  This class models only
  32.     the Visible property of the Application object.}
  33.   TGraphChartApp = class(TOleObject)
  34.   private
  35.     function GetVisible : Boolean;
  36.     procedure SetVisible(vis : Boolean);
  37.   public
  38.     property Visible : Boolean read GetVisible write SetVisible;
  39.   end;
  40.  
  41.   { Describes top-level MSGraph.Chart server object.  This
  42.     class models only the Application property (sub-object)
  43.     of the server. }
  44.   TGraphChart = class(TOLEObject)
  45.   private
  46.     FApplication : TGraphChartApp;
  47.     function GetApplication : TGraphChartApp;
  48.     procedure SetApplication(app : TGraphChartApp);
  49.   public
  50.     property Application : TGraphChartApp
  51.                 read GetApplication write SetApplication;
  52.     destructor Release; override;
  53.   end;
  54.  
  55. {***************************************************************************}
  56. implementation
  57. {***************************************************************************}
  58.  
  59. destructor TGraphChart.Release;
  60. begin
  61.   { Override destructor to free up the private FApplication
  62.     sub-object if it has been created. }
  63.   if Assigned(FApplication) then
  64.     FApplication.Release;
  65.   inherited Release;
  66. end;
  67.  
  68. function TGraphChart.GetApplication : TGraphChartApp;
  69. var
  70.   pApp : pInterface;
  71. begin
  72.   if Assigned(FApplication) then
  73.     Result := FApplication
  74.   else
  75.   begin
  76.     GetOleProperty('Application', 'pInterface', pApp);
  77.     if Assigned(pApp) then
  78.     begin
  79.       FApplication := TGraphChartApp.ConnectInterface(pApp);
  80.       Result := FApplication;
  81.     end
  82.     else
  83.       Result := nil;
  84.   end;
  85. end;
  86.  
  87. procedure TGraphChart.SetApplication(app : TGraphChartApp);
  88. begin
  89.   FApplication := app;
  90. end;
  91.  
  92. function TGraphChartApp.GetVisible : Boolean;
  93. var
  94.   intvis : Integer;
  95. begin
  96.   GetOleProperty('Visible', 'Integer', intvis);
  97.   Result := Boolean(intvis);
  98. end;
  99.  
  100. procedure TGraphChartApp.SetVisible(vis : Boolean);
  101. var
  102.   intvis : Integer;
  103. begin
  104.   intvis := Integer(vis);
  105.   SetOleProperty('Visible', 'Integer', intvis);
  106. end;
  107.  
  108. end.
  109.